<?php
$id = $_GET['id'];
$info = sel_sql($menu, "*", "id=$id");
$jibie = sel_arr_sql($menu, "*", "parentid=0");
$role = sel_arr_sql($role, "*", "status=1");

$sql="select role_id from ".$BIAOTOU."access where menu_id=".$id;
$query=mysql_query($sql);
while($row=mysql_fetch_array($query)){
    $qx_arr[$row['role_id']]=1;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理中心</title>
<link href="../css/style.css" rel="stylesheet" type="text/css">
<style>
.redborder{ border:1px solid #F00}
</style>
<script language="javascript" type="text/javascript" src="../../js/jquery.js"></script>
<script language="javascript" type="text/javascript">	
$(function(){
	<?php if($info["parentid"]>0){?>
	$.post("admin.php?act=post",{id:<?=$info["parentid"]?>},function(result){$(".qx2").html(result)});
	<?php }?>
    
	$('.qx1').change(function(event){  
		txt=$('.qx1').val();
		$.post("admin.php?act=post",{id:txt},function(result){
		    $(".qx2").html(result)
	    });
    });
    $('#form1').submit(function(){
		var subm=1;
	    $('.required').each(function(){
		    if($(this).val()==''){
			    $(this).focus().addClass('redborder');
				alert('该字段不能为空');
				subm=0;
				return false;
			}
		});
		if(subm==0) return false;
		if(subm==1) return true;
	});
	$('.required').blur(function(){
	    if($(this).val()!=''){
		    $(this).removeClass('redborder')
		}
	});
});
</script>
<style type="text/css">
<!--
.STYLE1 {
	color: #FFFFFF;
	font-weight: bold;
	font-size:14px;
	text-decoration:none;
}
.STYLE2 {
	color: #555555;
	font-weight: bold;
	font-size:14px;
	text-decoration:none;
}
-->
</style>
</head>

<body topmargin="5" leftmargin="0">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="282" valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td>
          <table cellspacing="0" valign="top" width="100%" height="" style="border:1px  solid #DCEAF7;">
            <tr>
              <td height="30" colspan="2" bgcolor="E9F2FB" class="bigtext"><strong>&nbsp;<img src="../images/arrow.gif" width="16" height="22" align="absmiddle" /> 添加新的菜单</strong></td>
            </tr>
            <tr>
              <td width="100%" colspan="2" valign="top"><table width="100%" height="300" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td valign="top"><form id="form1" name="form1" method="post" action="admin.php?act=savemenu">
<table width="100%"  align="center" border=1 cellpadding=0 cellspacing=0 style="border-collapse: collapse" bordercolor="#dddddd">
                      
					   <tr>
                        <td width="96" height="40" align="right" class="bigtext">菜单名称：</td>
                        <td height="30">&nbsp;<input id="adminname" type="text" name="info[name]" class="btn3 required" value="<?=$info['name']?>" style="width:200px;" /></td>
                        </tr>
                       <tr>
                        <td width="96" height="40" align="right" class="bigtext">菜单url：</td>
                        <td height="30" class="bigtext">&nbsp;<input name="info[url]" type="text" value="<?=$info['url']?$info['url']:$_GET['u']?>" class="btn3  "  style="width:200px;" /></td>
                        <tr>
                        <td width="96" height="30" align="right" class="bigtext">上级菜单：&nbsp;</td>
                        <td height="30" class="bigtext">
                          <div style="float:left"> 一级：
                            <select name="info[parentid]" class="qx1" id="info[parentid]">
                              <option value="0">作为根级别</option>
                              <?php foreach($jibie as $key => $r) {?>
                              <option <?php if ($r["id"] == $info["parentid"]) {echo 'selected="selected"';} ?> value="<?php echo $r["id"]?>"><?php echo $r["name"]?>(<?=$r["id"]?>)</option>
                              <?php } ?>
                              </select></div>
                          <div style="float:left" class="qx2" > 
                            </div></td>
                        </tr>
                         <tr>
                        <td width="96" height="40" align="right" class="bigtext">排序：</td>
                        <td height="30" class="bigtext">&nbsp;<input name="info[listorder]" type="text" value="<?=$info['listorder']?>" class="btn3 "  style="width:200px;" /></td>
                         
                         <tr>
                           <td height="30" align="right" class="bigtext">是否显示：</td>
                           <td height="30">&nbsp;<select name="info[status]" id="info[status]">
                           <option <?php if ($info["status"] == 1) {echo 'selected="selected"';} ?> value="1">显示</option>
                           <option <?php if ($info["status"] == 0) {echo 'selected="selected"';} ?> value="0">不显示</option>
                           </select>
                             </td>
                         </tr>
                         <tr>
                           <td height="30" align="right" class="bigtext">权限组：</td>
                           <td height="30">&nbsp;<?php foreach($role as $row) {?>
                               <label><?=$row['name']?>:<input type="checkbox" <?php if($qx_arr[$row['id']]==1){?> checked="checked"<?php }?> value="1" name="role_id[<?=$row['id']?>]" /></label>&nbsp;&nbsp;&nbsp;
                               <?php }?>
                           </td>
                         </tr>
                         <tr>
                        <td height="30" align="right" class="bigtext">提交：</td>
                        <td height="30"><table width="600" height="30" border="0" cellpadding="0" cellspacing="0">
                          <tr>
                            <td>&nbsp;                              <input type="submit" name="Submit" value=" 确认提交 " />
                              </td>
                            </tr>
  </table></td><input type="hidden" name="info[id]" value="<?=$info['id']?>"  />
                      </tr>
                    </table>
                  </form>
                  </td>
                </tr>
              </table></td>
            </tr>
          </table></td>
        </tr>
      
    </table></td>
  </tr>
</table>
<?php mysql_close();
?>
</body>
</html>